package com.xinyue.design.composite;

public class Client {

	public static void main(String[] args) {
		//定义root节点
		Component root = new Composite();
		//定义多个容器节点对象
		Component c1 = new Composite();
		Component c2 = new Composite();
		//定义多个子叶节点
		Component l1 = new Leaf();
		Component l2 = new Leaf();
		Component l3 = new Leaf();
		
		//组合成为树形的对象结构
		root.addChild(c1);
		root.addChild(c2);
		c1.addChild(l1);
		c2.addChild(l2);
		c2.addChild(l3);
		
		//调用
		//root.getChildren(0).getChildren(0).tryOn();
		//root.getChildren(1).tryOn();
		root.tryOn();
	}
}
